<template>
    <div class="heightBox">
        <div class="header">
            <div class="head-bg" :style="{'background-image':`url(${songBoxPic})`}">

            </div>
            <div class="wrap">
                <div class="img">
                    <img :src="songBoxPic">
                    <span class="songListText">歌单</span>
                    <i class="listenerNumber">{{setPlayCount(listenerNumber)}}</i>
                </div>
                <div class="title-author">
                    <div class="title">
                        {{boxTitle}}
                    </div>
                    <div class="author">
                        <div class="author-head">
                            <img :src="authorPic" >
                            <span class="xingxing"></span>
                        </div>
                        <div class="authodName">
                            {{author}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="synopsis" v-if="synopsis.length!=0">
            <div class="tag">
                标签：
                <div class="tagContent" v-for="(tag,index) in tags" :key="index">
                    {{tag}}
                </div>
            </div>
            <div class="padBot">
                <div class="synopsisText" @click="setShow" :class="{show:changeShow}" >
                   <span> 简介：</span><span class="text" v-for="(ayno,index) in synopsis" :key="index">{{ayno}} <br></span>
                </div>
                <span class="arrow" :class="{arrowdown:arrowDown,arrowup:arrowUp}"></span>
            </div>
        </div>
        <div class="songList">
            <div class="stitle">歌曲列表</div>
            <music v-bind="song" v-for="(song,index) in songList" :key="index" :index="index"></music>
        </div>
        <div class="comment-box">
            <div class="comment-title">精彩评论</div> 
             <comtent v-for="(item,index) in hotConment" v-bind="item"  :key="index"></comtent>
        </div>
        <div class="footer">
            <div class="footer-wrap">
                <span>收藏歌单</span>
            </div>
        </div>
    </div>
</template>
<script>
import music from '@/components/music-T'
import axios from 'axios'
import api from '@/api/index.js'
import comtent from '@/components/comment-T'
export default {
    components:{
        music,
        comtent
    },
    data(){
        return {
            songList:[],
            songBoxPic:"",
            boxTitle:"",
            author:"",
            authorPic:"",
            listenerNumber:Number,
            synopsis:[],
            tags:[],
            newConment:[],
            hotConment:[],
            changeShow:false,
            arrowDown:true,
            arrowUp:false
        }
    },
    methods:{
        hideHeader_Nav(){
            this.$store.commit("setshowHeader",{
            showHeader:false
            });
            this.$store.commit("setshowNav",{
            showNav:false
            });
        },
        setPlayCount(playCount){
            var sum;
            if(playCount<100000000){
                sum=((playCount/10000).toFixed(1))+"万";
                return sum ;
            }
            else{
                sum=((playCount/100000000).toFixed(1))+"亿";
                return sum;
            }
            
        },
        setShow(){
            // 简介隐藏，展开功能
            this.changeShow=!this.changeShow;
            // 箭头向下向上功能
            this.arrowDown=!this.arrowDown;

            this.arrowUp=!this.arrowUp;
        },
        // 获取歌单
        getsongList(){
            // var id=this.$route.fullPath.slice(this.$route.fullPath.indexOf("=")+1);
            // console.log(id)
            axios.get(api.recommentSong,{
                params:{
                    id:this.$route.query.id
                }
            }).then((res)=>{
                console.log(res);
                this.songList=res.data.playlist.tracks;
                
                this.songBoxPic=res.data.playlist.coverImgUrl;
                this.boxTitle=res.data.playlist.name;
                this.author=res.data.playlist.creator.nickname;
                this.authorPic=res.data.playlist.creator.avatarUrl;
                this.listenerNumber=res.data.playlist.playCount;
                console.log(this.synopsis)
                this.tags=res.data.playlist.tags;
                if(res.data.playlist.description!=""){
                     this.synopsis=(res.data.playlist.description).split("\n");
                }
                console.log(this.songList)
            })
        },
        // 获取歌单评论
        getUserContent(){
            axios.get(api.userComment,{
                params:{
                    id:this.$route.query.id
                }
            })
            .then((res)=>{
                console.log(res)
                this.newConment=res.data.comments;
                this.hotConment=res.data.hotComments;
                console.log(res.data.hotComments)
            })
            .catch((error)=>{
                console.log(error)
            })
        }
    },
    mounted(){

        this.hideHeader_Nav();
        this.getsongList();
        this.getUserContent();

    }
}
</script>
<style lang="scss" scoped>
.heightBox{
    height: 100%;
    font-size: 14px;
    .header{
        position: relative;
        padding: 30px 10px 30px 15px;
        overflow: hidden;
    }
    .head-bg{
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
        background-repeat: no-repeat;
        background-size: cover;
        background-position: 50%;
        -webkit-filter: blur(20px);
        filter: blur(20px);
        -webkit-transform: scale(1.5);
        transform: scale(1.5);
        background-image: url(//music.163.com/api/img/blur/109951163648627593?param=170y170);
    }
    .head-bg:after{
        content: " ";
        background-color: rgba(0,0,0,.25);
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
    }
    .wrap{
        
        display: flex;
        .img{
            width: 126px;
            height: 126px;
            position: relative;
            z-index: 2;
            img{
                width: 100%;
                height: 100%;
            }
            .songListText{
                position: absolute;
                z-index: 3;
                top: 10px;
                left: 0;
                padding: 0 8px;
                height: 17px;
                color: #fff;
                font-size: 9px;
                text-align: center;
                line-height: 17px;
                background-color: rgba(217,48,48,.8);
                border-top-right-radius: 17px;
                border-bottom-right-radius: 17px;
            }
            .listenerNumber{
                position: absolute;
                right: 2px;
                top: 0;
                z-index: 3;
                padding-left: 15px;
                color: #fff;
                font-size: 12px;
                background-position: 0;
                background-repeat: no-repeat;
                background-size: 11px 10px;
                text-shadow: 1px 0 0 rgba(0,0,0,.15);
                background-image: url();


            }
            .listenerNumber::after{
                content: " ";
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 18px;
                z-index: 2;
                background-image: linear-gradient(90deg,transparent,rgba(0,0,0,.2));
            }
        }
        .title-author{
            color: hsla(0,0%,100%,.7);
            font-size: 14px;
            z-index: 2;
            -webkit-box-flex: 1;
            -webkit-flex: 1 1 auto;
            flex: 1 1 auto;
            width: 1%;
            margin-left: 16px;
            .title{
                padding-top: 1px;
                font-size: 17px;
                line-height: 1.3;
                color: #fefefe;
                height: 44px;
                display: -webkit-box;
                -webkit-box-pack: center;
            }
            .author{
                    display: block;
                    position: relative;
                    margin-top: 20px;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    word-break: normal;
                .author-head{
                    display: inline-block;
                    width: 30px;    
                    height: 30px;
                    border-radius: 50%;
                    vertical-align: middle;
                    margin-right: 5px;
                    position: relative;
                    img{
                        width: 100%;
                        height: 100%;
                        border-radius: 50%;
                        vertical-align: middle;
                    }
                    .xingxing{
                        background-position: -40px 0;
                        position: absolute;
                        right: -5px;
                        bottom: 0;
                        width: 12px;
                        height: 12px;
                        background-image: url(//s3.music.126.net/m/s/img/usericn_2x.png?6423c06…);
                        background-repeat: no-repeat;
                        background-size: 75px auto;
                    }
                    
                }
                .authodName{
                    display: inline-block;
                }
            }
        }
    }
    .synopsis{
        position: relative;
        margin: 0 10px 0 15px;
        padding-top: 10px;
        line-height: 19px;
        color: #666;
        .tag{
            margin-bottom: 10px;
            line-height: 20px;
            margin-right: -10px;
            color: #666;
            .tagContent{
                display: inline-block;
                margin-right: 10px;
                padding: 1px 8px;
                font-size: 12px;
                position: relative;
            }
            .tagContent:after{
                border-radius: 9999px;
                -webkit-transform: scale(.5);
                transform: scale(.5);
                border-width: 1px;
                position: absolute;
                z-index: 2;
                content: "";
                top: 0;
                left: 0;
                pointer-events: none;
                box-sizing: border-box;
                width: 200%;
                height: 200%;
                transform-origin: top left;
                border: 1px solid rgba(0,0,0,.1);
            }
        }
        .padBot{
            padding-bottom: 18px;
            position: relative;
            .synopsisText{
                word-wrap: break-word;
                word-break: break-all;
                white-space: normal;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 3;
                -webkit-box-orient: vertical;
                span{
                 
                    line-height: 19px;
                }
            }
            .show{
                -webkit-line-clamp:100;
            }
            .arrow{
                position: absolute;
                bottom: 3px;
                right: 0;
                z-index: 3;
                width: 15px;
                height: 15px;
                background-position: 50%;
                background-repeat: no-repeat;
                background-size: 12px auto;
            }
            .arrowdown{
                 background-image: url();
            }
            .arrowup{
                background-image: url();
            }
        }
        
    }
    .songList{
        .stitle{
            height: 23px;
            line-height: 23px;
            padding: 0 10px;
            font-size: 12px;
            color: #666;
            background-color: #eeeff0;
        }
    }
    .comment-box{
        .comment-title{
            margin: 0;
            padding: 4px 10px;
            color: #666;
            font-size: 12px;
            font-weight: 400;
            background: rgba(0,0,0,.05);
        }
    }
    .footer{
        position: fixed;
        background-color: #fff;
        bottom: 0;
        width: 100%;

        .footer-wrap{
            padding-left: 30px;
            padding-right: 30px;
            padding-top: 7px;
            padding-bottom: 7px;
            margin: 0 auto;
            span{
                margin-left: 0;
                position: relative;
                color: #fff;
                background-color: #d33a31;
                border-color: #d33a31;
                display: inline-block;
                height: 40px;
                line-height: 40px;
                padding: 0 6px;
                border: 1px solid #adadad;
                border-radius: 40px;
                font-size: 17px;
                text-align: center;
                box-sizing: border-box;
                width: 100%;
                cursor: pointer;
            }
            span:after{
                    content: "";
                    display: inline-block;
                    position: relative;
                    top: 5px;
                    left: -60px;
                    width: 21px;
                    height: 23px;
                    background: url() no-repeat;
                    background-size: contain;
                    margin-right: 4px;
            }
        }
    }
}

</style>
